<?php
if (session_id() == "") session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include_once "ewcfg10.php" ?>
<?php include_once "ewmysql10.php" ?>
<?php include_once "phpfn10.php" ?>
<?php include_once "noticiasinfo.php" ?>
<?php include_once "usuariosinfo.php" ?>
<?php include_once "userfn10.php" ?>
<?php

//
// Page class
//

$noticias_edit = NULL; // Initialize page object first

class cnoticias_edit extends cnoticias {

	// Page ID
	var $PageID = 'edit';

	// Project ID
	var $ProjectID = "{1969EBBB-AC71-402B-89D8-7090C8C20C47}";

	// Table name
	var $TableName = 'noticias';

	// Page object name
	var $PageObjName = 'noticias_edit';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		if ($this->UseTokenInUrl) $PageUrl .= "t=" . $this->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v);
	}

	function getFailureMessage() {
		return @$_SESSION[EW_SESSION_FAILURE_MESSAGE];
	}

	function setFailureMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v);
	}

	function getSuccessMessage() {
		return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE];
	}

	function setSuccessMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v);
	}

	function getWarningMessage() {
		return @$_SESSION[EW_SESSION_WARNING_MESSAGE];
	}

	function setWarningMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_WARNING_MESSAGE], $v);
	}

	// Show message
	function ShowMessage() {
		$hidden = FALSE;
		$html = "";

		// Message
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage, "");
		if ($sMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sMessage;
			$html .= "<div class=\"alert alert-success ewSuccess\">" . $sMessage . "</div>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}

		// Warning message
		$sWarningMessage = $this->getWarningMessage();
		$this->Message_Showing($sWarningMessage, "warning");
		if ($sWarningMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sWarningMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sWarningMessage;
			$html .= "<div class=\"alert alert-warning ewWarning\">" . $sWarningMessage . "</div>";
			$_SESSION[EW_SESSION_WARNING_MESSAGE] = ""; // Clear message in Session
		}

		// Success message
		$sSuccessMessage = $this->getSuccessMessage();
		$this->Message_Showing($sSuccessMessage, "success");
		if ($sSuccessMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sSuccessMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sSuccessMessage;
			$html .= "<div class=\"alert alert-success ewSuccess\">" . $sSuccessMessage . "</div>";
			$_SESSION[EW_SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
		}

		// Failure message
		$sErrorMessage = $this->getFailureMessage();
		$this->Message_Showing($sErrorMessage, "failure");
		if ($sErrorMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sErrorMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sErrorMessage;
			$html .= "<div class=\"alert alert-error ewError\">" . $sErrorMessage . "</div>";
			$_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
		}
		echo "<table class=\"ewStdTable\"><tr><td><div class=\"ewMessageDialog\"" . (($hidden) ? " style=\"display: none;\"" : "") . ">" . $html . "</div></td></tr></table>";
	}
	var $PageHeader;
	var $PageFooter;

	// Show Page Header
	function ShowPageHeader() {
		$sHeader = $this->PageHeader;
		$this->Page_DataRendering($sHeader);
		if ($sHeader <> "") { // Header exists, display
			echo "<p>" . $sHeader . "</p>";
		}
	}

	// Show Page Footer
	function ShowPageFooter() {
		$sFooter = $this->PageFooter;
		$this->Page_DataRendered($sFooter);
		if ($sFooter <> "") { // Footer exists, display
			echo "<p>" . $sFooter . "</p>";
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm;
		if ($this->UseTokenInUrl) {
			if ($objForm)
				return ($this->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($this->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function __construct() {
		global $conn, $Language;
		$GLOBALS["Page"] = &$this;

		// Language object
		if (!isset($Language)) $Language = new cLanguage();

		// Parent constuctor
		parent::__construct();

		// Table object (noticias)
		if (!isset($GLOBALS["noticias"]) || get_class($GLOBALS["noticias"]) == "cnoticias") {
			$GLOBALS["noticias"] = &$this;
			$GLOBALS["Table"] = &$GLOBALS["noticias"];
		}

		// Table object (usuarios)
		if (!isset($GLOBALS['usuarios'])) $GLOBALS['usuarios'] = new cusuarios();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'edit', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'noticias', TRUE);

		// Start timer
		if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer();

		// Open connection
		if (!isset($conn)) $conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		$Security->TablePermission_Loading();
		$Security->LoadCurrentUserLevel($this->ProjectID . $this->TableName);
		$Security->TablePermission_Loaded();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		if (!$Security->CanEdit()) {
			$Security->SaveLastUrl();
			$this->setFailureMessage($Language->Phrase("NoPermission")); // Set no permission
			$this->Page_Terminate("noticiaslist.php");
		}

		// Create form object
		$objForm = new cFormObj();
		$this->CurrentAction = (@$_GET["a"] <> "") ? $_GET["a"] : @$_POST["a_list"]; // Set up current action
		$this->NoticiaId->Visible = !$this->IsAdd() && !$this->IsCopy() && !$this->IsGridAdd();

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();
		$this->Page_Redirecting($url);

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $DbMasterFilter;
	var $DbDetailFilter;

	// 
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError;

		// Load key from QueryString
		if (@$_GET["NoticiaId"] <> "") {
			$this->NoticiaId->setQueryStringValue($_GET["NoticiaId"]);
		}

		// Set up Breadcrumb
		$this->SetupBreadcrumb();

		// Process form if post back
		if (@$_POST["a_edit"] <> "") {
			$this->CurrentAction = $_POST["a_edit"]; // Get action code
			$this->LoadFormValues(); // Get form values
		} else {
			$this->CurrentAction = "I"; // Default action is display
		}

		// Check if valid key
		if ($this->NoticiaId->CurrentValue == "")
			$this->Page_Terminate("noticiaslist.php"); // Invalid key, return to list

		// Validate form if post back
		if (@$_POST["a_edit"] <> "") {
			if (!$this->ValidateForm()) {
				$this->CurrentAction = ""; // Form error, reset action
				$this->setFailureMessage($gsFormError);
				$this->EventCancelled = TRUE; // Event cancelled
				$this->RestoreFormValues();
			}
		}
		switch ($this->CurrentAction) {
			case "I": // Get a record to display
				if (!$this->LoadRow()) { // Load record based on key
					if ($this->getFailureMessage() == "") $this->setFailureMessage($Language->Phrase("NoRecord")); // No record found
					$this->Page_Terminate("noticiaslist.php"); // No matching record, return to list
				}
				break;
			Case "U": // Update
				$this->SendEmail = TRUE; // Send email on update success
				if ($this->EditRow()) { // Update record based on key
					if ($this->getSuccessMessage() == "")
						$this->setSuccessMessage($Language->Phrase("UpdateSuccess")); // Update success
					$sReturnUrl = $this->getReturnUrl();
					$this->Page_Terminate($sReturnUrl); // Return to caller
				} else {
					$this->EventCancelled = TRUE; // Event cancelled
					$this->RestoreFormValues(); // Restore form values if update failed
				}
		}

		// Render the record
		$this->RowType = EW_ROWTYPE_EDIT; // Render as Edit
		$this->ResetAttrs();
		$this->RenderRow();
	}

	// Set up starting record parameters
	function SetUpStartRec() {
		if ($this->DisplayRecs == 0)
			return;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter
				$this->StartRec = $_GET[EW_TABLE_START_REC];
				$this->setStartRecordNumber($this->StartRec);
			} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
				$PageNo = $_GET[EW_TABLE_PAGE_NO];
				if (is_numeric($PageNo)) {
					$this->StartRec = ($PageNo-1)*$this->DisplayRecs+1;
					if ($this->StartRec <= 0) {
						$this->StartRec = 1;
					} elseif ($this->StartRec >= intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1) {
						$this->StartRec = intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1;
					}
					$this->setStartRecordNumber($this->StartRec);
				}
			}
		}
		$this->StartRec = $this->getStartRecordNumber();

		// Check if correct start record counter
		if (!is_numeric($this->StartRec) || $this->StartRec == "") { // Avoid invalid start record counter
			$this->StartRec = 1; // Reset start record counter
			$this->setStartRecordNumber($this->StartRec);
		} elseif (intval($this->StartRec) > intval($this->TotalRecs)) { // Avoid starting record > total records
			$this->StartRec = intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1; // Point to last page first record
			$this->setStartRecordNumber($this->StartRec);
		} elseif (($this->StartRec-1) % $this->DisplayRecs <> 0) {
			$this->StartRec = intval(($this->StartRec-1)/$this->DisplayRecs)*$this->DisplayRecs+1; // Point to page boundary
			$this->setStartRecordNumber($this->StartRec);
		}
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm;

		// Get upload data
		$this->NoticiaImagen->Upload->Index = $objForm->Index;
		if ($this->NoticiaImagen->Upload->UploadFile()) {

			// No action required
		} else {
			echo $this->NoticiaImagen->Upload->Message;
			$this->Page_Terminate();
			exit();
		}
		$this->NoticiaImagen->CurrentValue = $this->NoticiaImagen->Upload->FileName;
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm;
		$this->GetUploadFiles(); // Get upload files
		if (!$this->NoticiaId->FldIsDetailKey)
			$this->NoticiaId->setFormValue($objForm->GetValue("x_NoticiaId"));
		if (!$this->NoticiaFecha->FldIsDetailKey) {
			$this->NoticiaFecha->setFormValue($objForm->GetValue("x_NoticiaFecha"));
			$this->NoticiaFecha->CurrentValue = ew_UnFormatDateTime($this->NoticiaFecha->CurrentValue, 7);
		}
		if (!$this->NoticiaTitulo->FldIsDetailKey) {
			$this->NoticiaTitulo->setFormValue($objForm->GetValue("x_NoticiaTitulo"));
		}
		if (!$this->NoticiaResumen->FldIsDetailKey) {
			$this->NoticiaResumen->setFormValue($objForm->GetValue("x_NoticiaResumen"));
		}
		if (!$this->NoticiaNoticia->FldIsDetailKey) {
			$this->NoticiaNoticia->setFormValue($objForm->GetValue("x_NoticiaNoticia"));
		}
		if (!$this->NoticiaPublicar->FldIsDetailKey) {
			$this->NoticiaPublicar->setFormValue($objForm->GetValue("x_NoticiaPublicar"));
		}
		if (!$this->NoticiaDestacada->FldIsDetailKey) {
			$this->NoticiaDestacada->setFormValue($objForm->GetValue("x_NoticiaDestacada"));
		}
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm;
		$this->LoadRow();
		$this->NoticiaId->CurrentValue = $this->NoticiaId->FormValue;
		$this->NoticiaFecha->CurrentValue = $this->NoticiaFecha->FormValue;
		$this->NoticiaFecha->CurrentValue = ew_UnFormatDateTime($this->NoticiaFecha->CurrentValue, 7);
		$this->NoticiaTitulo->CurrentValue = $this->NoticiaTitulo->FormValue;
		$this->NoticiaResumen->CurrentValue = $this->NoticiaResumen->FormValue;
		$this->NoticiaNoticia->CurrentValue = $this->NoticiaNoticia->FormValue;
		$this->NoticiaPublicar->CurrentValue = $this->NoticiaPublicar->FormValue;
		$this->NoticiaDestacada->CurrentValue = $this->NoticiaDestacada->FormValue;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $Language;
		$sFilter = $this->KeyFilter();

		// Call Row Selecting event
		$this->Row_Selecting($sFilter);

		// Load SQL based on filter
		$this->CurrentFilter = $sFilter;
		$sSql = $this->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn;
		if (!$rs || $rs->EOF) return;

		// Call Row Selected event
		$row = &$rs->fields;
		$this->Row_Selected($row);
		$this->NoticiaId->setDbValue($rs->fields('NoticiaId'));
		$this->NoticiaFecha->setDbValue($rs->fields('NoticiaFecha'));
		$this->NoticiaTitulo->setDbValue($rs->fields('NoticiaTitulo'));
		$this->NoticiaImagen->Upload->DbValue = $rs->fields('NoticiaImagen');
		$this->NoticiaImagen->CurrentValue = $this->NoticiaImagen->Upload->DbValue;
		$this->NoticiaResumen->setDbValue($rs->fields('NoticiaResumen'));
		$this->NoticiaNoticia->setDbValue($rs->fields('NoticiaNoticia'));
		$this->NoticiaPublicar->setDbValue($rs->fields('NoticiaPublicar'));
		$this->NoticiaDestacada->setDbValue($rs->fields('NoticiaDestacada'));
	}

	// Load DbValue from recordset
	function LoadDbValues(&$rs) {
		if (!$rs || !is_array($rs) && $rs->EOF) return;
		$row = is_array($rs) ? $rs : $rs->fields;
		$this->NoticiaId->DbValue = $row['NoticiaId'];
		$this->NoticiaFecha->DbValue = $row['NoticiaFecha'];
		$this->NoticiaTitulo->DbValue = $row['NoticiaTitulo'];
		$this->NoticiaImagen->Upload->DbValue = $row['NoticiaImagen'];
		$this->NoticiaResumen->DbValue = $row['NoticiaResumen'];
		$this->NoticiaNoticia->DbValue = $row['NoticiaNoticia'];
		$this->NoticiaPublicar->DbValue = $row['NoticiaPublicar'];
		$this->NoticiaDestacada->DbValue = $row['NoticiaDestacada'];
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language;
		global $gsLanguage;

		// Initialize URLs
		// Call Row_Rendering event

		$this->Row_Rendering();

		// Common render codes for all row types
		// NoticiaId
		// NoticiaFecha
		// NoticiaTitulo
		// NoticiaImagen
		// NoticiaResumen
		// NoticiaNoticia
		// NoticiaPublicar
		// NoticiaDestacada

		if ($this->RowType == EW_ROWTYPE_VIEW) { // View row

			// NoticiaId
			$this->NoticiaId->ViewValue = $this->NoticiaId->CurrentValue;
			$this->NoticiaId->ViewCustomAttributes = "";

			// NoticiaFecha
			$this->NoticiaFecha->ViewValue = $this->NoticiaFecha->CurrentValue;
			$this->NoticiaFecha->ViewValue = ew_FormatDateTime($this->NoticiaFecha->ViewValue, 7);
			$this->NoticiaFecha->ViewCustomAttributes = "";

			// NoticiaTitulo
			$this->NoticiaTitulo->ViewValue = $this->NoticiaTitulo->CurrentValue;
			$this->NoticiaTitulo->ViewCustomAttributes = "";

			// NoticiaImagen
			if (!ew_Empty($this->NoticiaImagen->Upload->DbValue)) {
				$this->NoticiaImagen->ViewValue = $this->NoticiaImagen->Upload->DbValue;
			} else {
				$this->NoticiaImagen->ViewValue = "";
			}
			$this->NoticiaImagen->ViewCustomAttributes = "";

			// NoticiaResumen
			$this->NoticiaResumen->ViewValue = $this->NoticiaResumen->CurrentValue;
			$this->NoticiaResumen->ViewCustomAttributes = "";

			// NoticiaNoticia
			$this->NoticiaNoticia->ViewValue = $this->NoticiaNoticia->CurrentValue;
			$this->NoticiaNoticia->ViewCustomAttributes = "";

			// NoticiaPublicar
			if (strval($this->NoticiaPublicar->CurrentValue) <> "") {
				$this->NoticiaPublicar->ViewValue = "";
				$arwrk = explode(",", strval($this->NoticiaPublicar->CurrentValue));
				$cnt = count($arwrk);
				for ($ari = 0; $ari < $cnt; $ari++) {
					switch (trim($arwrk[$ari])) {
						case $this->NoticiaPublicar->FldTagValue(1):
							$this->NoticiaPublicar->ViewValue .= $this->NoticiaPublicar->FldTagCaption(1) <> "" ? $this->NoticiaPublicar->FldTagCaption(1) : trim($arwrk[$ari]);
							break;
						default:
							$this->NoticiaPublicar->ViewValue .= trim($arwrk[$ari]);
					}
					if ($ari < $cnt-1) $this->NoticiaPublicar->ViewValue .= ew_ViewOptionSeparator($ari);
				}
			} else {
				$this->NoticiaPublicar->ViewValue = NULL;
			}
			$this->NoticiaPublicar->ViewCustomAttributes = "";

			// NoticiaDestacada
			if (strval($this->NoticiaDestacada->CurrentValue) <> "") {
				$this->NoticiaDestacada->ViewValue = "";
				$arwrk = explode(",", strval($this->NoticiaDestacada->CurrentValue));
				$cnt = count($arwrk);
				for ($ari = 0; $ari < $cnt; $ari++) {
					switch (trim($arwrk[$ari])) {
						case $this->NoticiaDestacada->FldTagValue(1):
							$this->NoticiaDestacada->ViewValue .= $this->NoticiaDestacada->FldTagCaption(1) <> "" ? $this->NoticiaDestacada->FldTagCaption(1) : trim($arwrk[$ari]);
							break;
						default:
							$this->NoticiaDestacada->ViewValue .= trim($arwrk[$ari]);
					}
					if ($ari < $cnt-1) $this->NoticiaDestacada->ViewValue .= ew_ViewOptionSeparator($ari);
				}
			} else {
				$this->NoticiaDestacada->ViewValue = NULL;
			}
			$this->NoticiaDestacada->ViewCustomAttributes = "";

			// NoticiaId
			$this->NoticiaId->LinkCustomAttributes = "";
			$this->NoticiaId->HrefValue = "";
			$this->NoticiaId->TooltipValue = "";

			// NoticiaFecha
			$this->NoticiaFecha->LinkCustomAttributes = "";
			$this->NoticiaFecha->HrefValue = "";
			$this->NoticiaFecha->TooltipValue = "";

			// NoticiaTitulo
			$this->NoticiaTitulo->LinkCustomAttributes = "";
			$this->NoticiaTitulo->HrefValue = "";
			$this->NoticiaTitulo->TooltipValue = "";

			// NoticiaImagen
			$this->NoticiaImagen->LinkCustomAttributes = "";
			$this->NoticiaImagen->HrefValue = "";
			$this->NoticiaImagen->HrefValue2 = $this->NoticiaImagen->UploadPath . $this->NoticiaImagen->Upload->DbValue;
			$this->NoticiaImagen->TooltipValue = "";

			// NoticiaResumen
			$this->NoticiaResumen->LinkCustomAttributes = "";
			$this->NoticiaResumen->HrefValue = "";
			$this->NoticiaResumen->TooltipValue = "";

			// NoticiaNoticia
			$this->NoticiaNoticia->LinkCustomAttributes = "";
			if (!empty($this->NoticiaNoticia->Upload->DbValue)) {
				$this->NoticiaNoticia->HrefValue = "noticias_NoticiaNoticia_bv.php?NoticiaId=" . $this->NoticiaId->CurrentValue;
				$this->NoticiaNoticia->LinkAttrs["target"] = "_blank";
				if ($this->Export <> "") $this->NoticiaNoticia->HrefValue = ew_ConvertFullUrl($this->NoticiaNoticia->HrefValue);
			} else {
				$this->NoticiaNoticia->HrefValue = "";
			}
			$this->NoticiaNoticia->TooltipValue = "";

			// NoticiaPublicar
			$this->NoticiaPublicar->LinkCustomAttributes = "";
			$this->NoticiaPublicar->HrefValue = "";
			$this->NoticiaPublicar->TooltipValue = "";

			// NoticiaDestacada
			$this->NoticiaDestacada->LinkCustomAttributes = "";
			$this->NoticiaDestacada->HrefValue = "";
			$this->NoticiaDestacada->TooltipValue = "";
		} elseif ($this->RowType == EW_ROWTYPE_EDIT) { // Edit row

			// NoticiaId
			$this->NoticiaId->EditCustomAttributes = "";
			$this->NoticiaId->EditValue = $this->NoticiaId->CurrentValue;
			$this->NoticiaId->ViewCustomAttributes = "";

			// NoticiaFecha
			$this->NoticiaFecha->EditCustomAttributes = "";
			$this->NoticiaFecha->EditValue = ew_HtmlEncode(ew_FormatDateTime($this->NoticiaFecha->CurrentValue, 7));
			$this->NoticiaFecha->PlaceHolder = ew_RemoveHtml($this->NoticiaFecha->FldCaption());

			// NoticiaTitulo
			$this->NoticiaTitulo->EditCustomAttributes = "";
			$this->NoticiaTitulo->EditValue = ew_HtmlEncode($this->NoticiaTitulo->CurrentValue);
			$this->NoticiaTitulo->PlaceHolder = ew_RemoveHtml($this->NoticiaTitulo->FldCaption());

			// NoticiaImagen
			$this->NoticiaImagen->EditCustomAttributes = "";
			if (!ew_Empty($this->NoticiaImagen->Upload->DbValue)) {
				$this->NoticiaImagen->EditValue = $this->NoticiaImagen->Upload->DbValue;
			} else {
				$this->NoticiaImagen->EditValue = "";
			}
			if (!ew_Empty($this->NoticiaImagen->CurrentValue))
				$this->NoticiaImagen->Upload->FileName = $this->NoticiaImagen->CurrentValue;
			if ($this->CurrentAction == "I" && !$this->EventCancelled) ew_RenderUploadField($this->NoticiaImagen);

			// NoticiaResumen
			$this->NoticiaResumen->EditCustomAttributes = "";
			$this->NoticiaResumen->EditValue = $this->NoticiaResumen->CurrentValue;
			$this->NoticiaResumen->PlaceHolder = ew_RemoveHtml($this->NoticiaResumen->FldCaption());

			// NoticiaNoticia
			$this->NoticiaNoticia->EditCustomAttributes = "";
			$this->NoticiaNoticia->EditValue = $this->NoticiaNoticia->CurrentValue;
			$this->NoticiaNoticia->PlaceHolder = ew_RemoveHtml($this->NoticiaNoticia->FldCaption());

			// NoticiaPublicar
			$this->NoticiaPublicar->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array($this->NoticiaPublicar->FldTagValue(1), $this->NoticiaPublicar->FldTagCaption(1) <> "" ? $this->NoticiaPublicar->FldTagCaption(1) : $this->NoticiaPublicar->FldTagValue(1));
			$this->NoticiaPublicar->EditValue = $arwrk;

			// NoticiaDestacada
			$this->NoticiaDestacada->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array($this->NoticiaDestacada->FldTagValue(1), $this->NoticiaDestacada->FldTagCaption(1) <> "" ? $this->NoticiaDestacada->FldTagCaption(1) : $this->NoticiaDestacada->FldTagValue(1));
			$this->NoticiaDestacada->EditValue = $arwrk;

			// Edit refer script
			// NoticiaId

			$this->NoticiaId->HrefValue = "";

			// NoticiaFecha
			$this->NoticiaFecha->HrefValue = "";

			// NoticiaTitulo
			$this->NoticiaTitulo->HrefValue = "";

			// NoticiaImagen
			$this->NoticiaImagen->HrefValue = "";
			$this->NoticiaImagen->HrefValue2 = $this->NoticiaImagen->UploadPath . $this->NoticiaImagen->Upload->DbValue;

			// NoticiaResumen
			$this->NoticiaResumen->HrefValue = "";

			// NoticiaNoticia
			if (!empty($this->NoticiaNoticia->Upload->DbValue)) {
				$this->NoticiaNoticia->HrefValue = "noticias_NoticiaNoticia_bv.php?NoticiaId=" . $this->NoticiaId->CurrentValue;
				$this->NoticiaNoticia->LinkAttrs["target"] = "_blank";
				if ($this->Export <> "") $this->NoticiaNoticia->HrefValue = ew_ConvertFullUrl($this->NoticiaNoticia->HrefValue);
			} else {
				$this->NoticiaNoticia->HrefValue = "";
			}

			// NoticiaPublicar
			$this->NoticiaPublicar->HrefValue = "";

			// NoticiaDestacada
			$this->NoticiaDestacada->HrefValue = "";
		}
		if ($this->RowType == EW_ROWTYPE_ADD ||
			$this->RowType == EW_ROWTYPE_EDIT ||
			$this->RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row
			$this->SetupFieldTitles();
		}

		// Call Row Rendered event
		if ($this->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$this->Row_Rendered();
	}

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError;

		// Initialize form error message
		$gsFormError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!ew_CheckEuroDate($this->NoticiaFecha->FormValue)) {
			ew_AddMessage($gsFormError, $this->NoticiaFecha->FldErrMsg());
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			ew_AddMessage($gsFormError, $sFormCustomError);
		}
		return $ValidateForm;
	}

	// Update record based on key values
	function EditRow() {
		global $conn, $Security, $Language;
		$sFilter = $this->KeyFilter();
		$this->CurrentFilter = $sFilter;
		$sSql = $this->SQL();
		$conn->raiseErrorFn = 'ew_ErrorFn';
		$rs = $conn->Execute($sSql);
		$conn->raiseErrorFn = '';
		if ($rs === FALSE)
			return FALSE;
		if ($rs->EOF) {
			$EditRow = FALSE; // Update Failed
		} else {

			// Save old values
			$rsold = &$rs->fields;
			$this->LoadDbValues($rsold);
			$rsnew = array();

			// NoticiaFecha
			$this->NoticiaFecha->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->NoticiaFecha->CurrentValue, 7), NULL, $this->NoticiaFecha->ReadOnly);

			// NoticiaTitulo
			$this->NoticiaTitulo->SetDbValueDef($rsnew, $this->NoticiaTitulo->CurrentValue, NULL, $this->NoticiaTitulo->ReadOnly);

			// NoticiaImagen
			if (!($this->NoticiaImagen->ReadOnly) && !$this->NoticiaImagen->Upload->KeepFile) {
				$this->NoticiaImagen->Upload->DbValue = $rs->fields('NoticiaImagen'); // Get original value
				if ($this->NoticiaImagen->Upload->FileName == "") {
					$rsnew['NoticiaImagen'] = NULL;
				} else {
					$rsnew['NoticiaImagen'] = $this->NoticiaImagen->Upload->FileName;
				}
			}

			// NoticiaResumen
			$this->NoticiaResumen->SetDbValueDef($rsnew, $this->NoticiaResumen->CurrentValue, NULL, $this->NoticiaResumen->ReadOnly);

			// NoticiaNoticia
			$this->NoticiaNoticia->SetDbValueDef($rsnew, $this->NoticiaNoticia->CurrentValue, NULL, $this->NoticiaNoticia->ReadOnly);

			// NoticiaPublicar
			$this->NoticiaPublicar->SetDbValueDef($rsnew, $this->NoticiaPublicar->CurrentValue, NULL, $this->NoticiaPublicar->ReadOnly);

			// NoticiaDestacada
			$this->NoticiaDestacada->SetDbValueDef($rsnew, $this->NoticiaDestacada->CurrentValue, NULL, $this->NoticiaDestacada->ReadOnly);
			if (!$this->NoticiaImagen->Upload->KeepFile) {
				if (!ew_Empty($this->NoticiaImagen->Upload->Value)) {
					$rsnew['NoticiaImagen'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->NoticiaImagen->UploadPath), $rsnew['NoticiaImagen']); // Get new file name
				}
			}

			// Call Row Updating event
			$bUpdateRow = $this->Row_Updating($rsold, $rsnew);
			if ($bUpdateRow) {
				$conn->raiseErrorFn = 'ew_ErrorFn';
				if (count($rsnew) > 0)
					$EditRow = $this->Update($rsnew, "", $rsold);
				else
					$EditRow = TRUE; // No field to update
				$conn->raiseErrorFn = '';
				if ($EditRow) {
					if (!$this->NoticiaImagen->Upload->KeepFile) {
						if (!ew_Empty($this->NoticiaImagen->Upload->Value)) {
							$this->NoticiaImagen->Upload->SaveToFile($this->NoticiaImagen->UploadPath, $rsnew['NoticiaImagen'], TRUE);
						}
					}
				}
			} else {
				if ($this->getSuccessMessage() <> "" || $this->getFailureMessage() <> "") {

					// Use the message, do nothing
				} elseif ($this->CancelMessage <> "") {
					$this->setFailureMessage($this->CancelMessage);
					$this->CancelMessage = "";
				} else {
					$this->setFailureMessage($Language->Phrase("UpdateCancelled"));
				}
				$EditRow = FALSE;
			}
		}

		// Call Row_Updated event
		if ($EditRow)
			$this->Row_Updated($rsold, $rsnew);
		$rs->Close();

		// NoticiaImagen
		ew_CleanUploadTempPath($this->NoticiaImagen, $this->NoticiaImagen->Upload->Index);
		return $EditRow;
	}

	// Set up Breadcrumb
	function SetupBreadcrumb() {
		global $Breadcrumb, $Language;
		$Breadcrumb = new cBreadcrumb();
		$Breadcrumb->Add("list", $this->TableVar, "noticiaslist.php", $this->TableVar, TRUE);
		$PageId = "edit";
		$Breadcrumb->Add("edit", $PageId, ew_CurrentUrl());
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	// $type = ''|'success'|'failure'|'warning'
	function Message_Showing(&$msg, $type) {
		if ($type == 'success') {

			//$msg = "your success message";
		} elseif ($type == 'failure') {

			//$msg = "your failure message";
		} elseif ($type == 'warning') {

			//$msg = "your warning message";
		} else {

			//$msg = "your message";
		}
	}

	// Page Render event
	function Page_Render() {

		//echo "Page Render";
	}

	// Page Data Rendering event
	function Page_DataRendering(&$header) {

		// Example:
		//$header = "your header";

	}

	// Page Data Rendered event
	function Page_DataRendered(&$footer) {

		// Example:
		//$footer = "your footer";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>
<?php ew_Header(FALSE) ?>
<?php

// Create page object
if (!isset($noticias_edit)) $noticias_edit = new cnoticias_edit();

// Page init
$noticias_edit->Page_Init();

// Page main
$noticias_edit->Page_Main();

// Global Page Rendering event (in userfn*.php)
Page_Rendering();

// Page Rendering event
$noticias_edit->Page_Render();
?>
<?php include_once "header.php" ?>
<script type="text/javascript">

// Page object
var noticias_edit = new ew_Page("noticias_edit");
noticias_edit.PageID = "edit"; // Page ID
var EW_PAGE_ID = noticias_edit.PageID; // For backward compatibility

// Form object
var fnoticiasedit = new ew_Form("fnoticiasedit");

// Validate form
fnoticiasedit.Validate = function() {
	if (!this.ValidateRequired)
		return true; // Ignore validation
	var $ = jQuery, fobj = this.GetForm(), $fobj = $(fobj);
	this.PostAutoSuggest();
	if ($fobj.find("#a_confirm").val() == "F")
		return true;
	var elm, felm, uelm, addcnt = 0;
	var $k = $fobj.find("#" + this.FormKeyCountName); // Get key_count
	var rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1;
	var startcnt = (rowcnt == 0) ? 0 : 1; // Check rowcnt == 0 => Inline-Add
	var gridinsert = $fobj.find("#a_list").val() == "gridinsert";
	for (var i = startcnt; i <= rowcnt; i++) {
		var infix = ($k[0]) ? String(i) : "";
		$fobj.data("rowindex", infix);
			elm = this.GetElements("x" + infix + "_NoticiaFecha");
			if (elm && !ew_CheckEuroDate(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($noticias->NoticiaFecha->FldErrMsg()) ?>");

			// Set up row object
			ew_ElementsToRow(fobj);

			// Fire Form_CustomValidate event
			if (!this.Form_CustomValidate(fobj))
				return false;
	}

	// Process detail forms
	var dfs = $fobj.find("input[name='detailpage']").get();
	for (var i = 0; i < dfs.length; i++) {
		var df = dfs[i], val = df.value;
		if (val && ewForms[val])
			if (!ewForms[val].Validate())
				return false;
	}
	return true;
}

// Form_CustomValidate event
fnoticiasedit.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }

// Use JavaScript validation or not
<?php if (EW_CLIENT_VALIDATE) { ?>
fnoticiasedit.ValidateRequired = true;
<?php } else { ?>
fnoticiasedit.ValidateRequired = false; 
<?php } ?>

// Dynamic selection lists
// Form object for search

</script>
<script type="text/javascript">

// Write your client script here, no need to add script tags.
</script>
<?php $Breadcrumb->Render(); ?>
<?php $noticias_edit->ShowPageHeader(); ?>
<?php
$noticias_edit->ShowMessage();
?>
<form name="fnoticiasedit" id="fnoticiasedit" class="ewForm form-inline" action="<?php echo ew_CurrentPage() ?>" method="post">
<input type="hidden" name="t" value="noticias">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table class="ewGrid"><tr><td>
<table id="tbl_noticiasedit" class="table table-bordered table-striped">
<?php if ($noticias->NoticiaId->Visible) { // NoticiaId ?>
	<tr id="r_NoticiaId">
		<td><span id="elh_noticias_NoticiaId"><?php echo $noticias->NoticiaId->FldCaption() ?></span></td>
		<td<?php echo $noticias->NoticiaId->CellAttributes() ?>>
<span id="el_noticias_NoticiaId" class="control-group">
<span<?php echo $noticias->NoticiaId->ViewAttributes() ?>>
<?php echo $noticias->NoticiaId->EditValue ?></span>
</span>
<input type="hidden" data-field="x_NoticiaId" name="x_NoticiaId" id="x_NoticiaId" value="<?php echo ew_HtmlEncode($noticias->NoticiaId->CurrentValue) ?>">
<?php echo $noticias->NoticiaId->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($noticias->NoticiaFecha->Visible) { // NoticiaFecha ?>
	<tr id="r_NoticiaFecha">
		<td><span id="elh_noticias_NoticiaFecha"><?php echo $noticias->NoticiaFecha->FldCaption() ?></span></td>
		<td<?php echo $noticias->NoticiaFecha->CellAttributes() ?>>
<span id="el_noticias_NoticiaFecha" class="control-group">
<input type="text" data-field="x_NoticiaFecha" name="x_NoticiaFecha" id="x_NoticiaFecha" size="11" placeholder="<?php echo ew_HtmlEncode($noticias->NoticiaFecha->PlaceHolder) ?>" value="<?php echo $noticias->NoticiaFecha->EditValue ?>"<?php echo $noticias->NoticiaFecha->EditAttributes() ?>>
<?php if (!$noticias->NoticiaFecha->ReadOnly && !$noticias->NoticiaFecha->Disabled && @$noticias->NoticiaFecha->EditAttrs["readonly"] == "" && @$noticias->NoticiaFecha->EditAttrs["disabled"] == "") { ?>
<button id="cal_x_NoticiaFecha" name="cal_x_NoticiaFecha" class="btn" type="button"><img src="phpimages/calendar.png" alt="<?php echo $Language->Phrase("PickDate") ?>" title="<?php echo $Language->Phrase("PickDate") ?>" style="border: 0;"></button><script type="text/javascript">
ew_CreateCalendar("fnoticiasedit", "x_NoticiaFecha", "%d/%m/%Y");
</script>
<?php } ?>
</span>
<?php echo $noticias->NoticiaFecha->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($noticias->NoticiaTitulo->Visible) { // NoticiaTitulo ?>
	<tr id="r_NoticiaTitulo">
		<td><span id="elh_noticias_NoticiaTitulo"><?php echo $noticias->NoticiaTitulo->FldCaption() ?></span></td>
		<td<?php echo $noticias->NoticiaTitulo->CellAttributes() ?>>
<span id="el_noticias_NoticiaTitulo" class="control-group">
<input type="text" data-field="x_NoticiaTitulo" name="x_NoticiaTitulo" id="x_NoticiaTitulo" size="30" maxlength="150" placeholder="<?php echo ew_HtmlEncode($noticias->NoticiaTitulo->PlaceHolder) ?>" value="<?php echo $noticias->NoticiaTitulo->EditValue ?>"<?php echo $noticias->NoticiaTitulo->EditAttributes() ?>>
</span>
<?php echo $noticias->NoticiaTitulo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($noticias->NoticiaImagen->Visible) { // NoticiaImagen ?>
	<tr id="r_NoticiaImagen">
		<td><span id="elh_noticias_NoticiaImagen"><?php echo $noticias->NoticiaImagen->FldCaption() ?></span></td>
		<td<?php echo $noticias->NoticiaImagen->CellAttributes() ?>>
<span id="el_noticias_NoticiaImagen" class="control-group">
<span id="fd_x_NoticiaImagen">
<span class="btn btn-small fileinput-button"<?php if ($noticias->NoticiaImagen->ReadOnly || $noticias->NoticiaImagen->Disabled) echo " style=\"display: none;\""; ?>>
	<span><?php echo $Language->Phrase("ChooseFile") ?></span>
	<input type="file" data-field="x_NoticiaImagen" name="x_NoticiaImagen" id="x_NoticiaImagen">
</span>
<input type="hidden" name="fn_x_NoticiaImagen" id= "fn_x_NoticiaImagen" value="<?php echo $noticias->NoticiaImagen->Upload->FileName ?>">
<?php if (@$_POST["fa_x_NoticiaImagen"] == "0") { ?>
<input type="hidden" name="fa_x_NoticiaImagen" id= "fa_x_NoticiaImagen" value="0">
<?php } else { ?>
<input type="hidden" name="fa_x_NoticiaImagen" id= "fa_x_NoticiaImagen" value="1">
<?php } ?>
<input type="hidden" name="fs_x_NoticiaImagen" id= "fs_x_NoticiaImagen" value="50">
</span>
<table id="ft_x_NoticiaImagen" class="table table-condensed pull-left ewUploadTable"><tbody class="files"></tbody></table>
</span>
<?php echo $noticias->NoticiaImagen->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($noticias->NoticiaResumen->Visible) { // NoticiaResumen ?>
	<tr id="r_NoticiaResumen">
		<td><span id="elh_noticias_NoticiaResumen"><?php echo $noticias->NoticiaResumen->FldCaption() ?></span></td>
		<td<?php echo $noticias->NoticiaResumen->CellAttributes() ?>>
<span id="el_noticias_NoticiaResumen" class="control-group">
<textarea data-field="x_NoticiaResumen" name="x_NoticiaResumen" id="x_NoticiaResumen" cols="45" rows="11" placeholder="<?php echo ew_HtmlEncode($noticias->NoticiaResumen->PlaceHolder) ?>"<?php echo $noticias->NoticiaResumen->EditAttributes() ?>><?php echo $noticias->NoticiaResumen->EditValue ?></textarea>
</span>
<?php echo $noticias->NoticiaResumen->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($noticias->NoticiaNoticia->Visible) { // NoticiaNoticia ?>
	<tr id="r_NoticiaNoticia">
		<td><span id="elh_noticias_NoticiaNoticia"><?php echo $noticias->NoticiaNoticia->FldCaption() ?></span></td>
		<td<?php echo $noticias->NoticiaNoticia->CellAttributes() ?>>
<span id="el_noticias_NoticiaNoticia" class="control-group">
<textarea data-field="x_NoticiaNoticia" class="editor" name="x_NoticiaNoticia" id="x_NoticiaNoticia" cols="4" rows="35" placeholder="<?php echo ew_HtmlEncode($noticias->NoticiaNoticia->PlaceHolder) ?>"<?php echo $noticias->NoticiaNoticia->EditAttributes() ?>><?php echo $noticias->NoticiaNoticia->EditValue ?></textarea>
<script type="text/javascript">
ew_CreateEditor("fnoticiasedit", "x_NoticiaNoticia", 0, 0, <?php echo ($noticias->NoticiaNoticia->ReadOnly || FALSE) ? "true" : "false" ?>);
</script>
</span>
<?php echo $noticias->NoticiaNoticia->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($noticias->NoticiaPublicar->Visible) { // NoticiaPublicar ?>
	<tr id="r_NoticiaPublicar">
		<td><span id="elh_noticias_NoticiaPublicar"><?php echo $noticias->NoticiaPublicar->FldCaption() ?></span></td>
		<td<?php echo $noticias->NoticiaPublicar->CellAttributes() ?>>
<span id="el_noticias_NoticiaPublicar" class="control-group">
<div id="tp_x_NoticiaPublicar" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME; ?>"><input type="checkbox" name="x_NoticiaPublicar[]" id="x_NoticiaPublicar[]" value="{value}"<?php echo $noticias->NoticiaPublicar->EditAttributes() ?>></div>
<div id="dsl_x_NoticiaPublicar" data-repeatcolumn="5" class="ewItemList">
<?php
$arwrk = $noticias->NoticiaPublicar->EditValue;
if (is_array($arwrk)) {
	$armultiwrk= explode(",", strval($noticias->NoticiaPublicar->CurrentValue));
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = "";
		$cnt = count($armultiwrk);
		for ($ari = 0; $ari < $cnt; $ari++) {
			if (strval($arwrk[$rowcntwrk][0]) == trim(strval($armultiwrk[$ari]))) {
				$selwrk = " checked=\"checked\"";
				if ($selwrk <> "") $emptywrk = FALSE;
				break;
			}
		}

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label class="checkbox"><input type="checkbox" data-field="x_NoticiaPublicar" name="x_NoticiaPublicar[]" id="x_NoticiaPublicar_<?php echo $rowcntwrk ?>[]" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $noticias->NoticiaPublicar->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span>
<?php echo $noticias->NoticiaPublicar->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($noticias->NoticiaDestacada->Visible) { // NoticiaDestacada ?>
	<tr id="r_NoticiaDestacada">
		<td><span id="elh_noticias_NoticiaDestacada"><?php echo $noticias->NoticiaDestacada->FldCaption() ?></span></td>
		<td<?php echo $noticias->NoticiaDestacada->CellAttributes() ?>>
<span id="el_noticias_NoticiaDestacada" class="control-group">
<div id="tp_x_NoticiaDestacada" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME; ?>"><input type="checkbox" name="x_NoticiaDestacada[]" id="x_NoticiaDestacada[]" value="{value}"<?php echo $noticias->NoticiaDestacada->EditAttributes() ?>></div>
<div id="dsl_x_NoticiaDestacada" data-repeatcolumn="5" class="ewItemList">
<?php
$arwrk = $noticias->NoticiaDestacada->EditValue;
if (is_array($arwrk)) {
	$armultiwrk= explode(",", strval($noticias->NoticiaDestacada->CurrentValue));
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = "";
		$cnt = count($armultiwrk);
		for ($ari = 0; $ari < $cnt; $ari++) {
			if (strval($arwrk[$rowcntwrk][0]) == trim(strval($armultiwrk[$ari]))) {
				$selwrk = " checked=\"checked\"";
				if ($selwrk <> "") $emptywrk = FALSE;
				break;
			}
		}

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label class="checkbox"><input type="checkbox" data-field="x_NoticiaDestacada" name="x_NoticiaDestacada[]" id="x_NoticiaDestacada_<?php echo $rowcntwrk ?>[]" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $noticias->NoticiaDestacada->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span>
<?php echo $noticias->NoticiaDestacada->CustomMsg ?></td>
	</tr>
<?php } ?>
</table>
</td></tr></table>
<button class="btn btn-primary ewButton" name="btnAction" id="btnAction" type="submit"><?php echo $Language->Phrase("EditBtn") ?></button>
</form>
<script type="text/javascript">
fnoticiasedit.Init();
<?php if (EW_MOBILE_REFLOW && ew_IsMobile()) { ?>
ew_Reflow();
<?php } ?>
</script>
<?php
$noticias_edit->ShowPageFooter();
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
?>
<script type="text/javascript">

// Write your table-specific startup script here
// document.write("page loaded");

</script>
<?php include_once "footer.php" ?>
<?php
$noticias_edit->Page_Terminate();
?>
